use bc_notifications::{config::Config, router::create_router};
use simple_logger::SimpleLogger;
use std::{error::Error, net::SocketAddr};

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    SimpleLogger::new().init()?;
    let config = envy::from_env::<Config>()?;

    let router = create_router(config.clone());

    axum::Server::bind(&([0, 0, 0, 0], config.app_port).into())
        .serve(router.into_make_service_with_connect_info::<SocketAddr>())
        .await
        .map_err(|x| Box::new(x) as Box<dyn Error>)
}
